<template>
	<view>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-p-t-30">
			<view class="u-m-r-10">
				<oss-upload></oss-upload>
			</view>
			<view class="u-flex-1 u-p-l-20">
				<view class="u-font-18 u-p-b-20">{{this.vuex_user.name}}</view>
				<view class="u-font-14 u-tips-color">邮箱:{{this.vuex_user.email}}</view>
			</view>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="photo" title="个人信息" @click="toModifyInfo"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="coupon" title="所有订单"></u-cell-item>
				<u-cell-item icon="map" title="收货地址"></u-cell-item>
				<u-cell-item icon="star" title="商品收藏"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="reload" title="退出登录" @tap="exitLogin"></u-cell-item>
			</u-cell-group>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {

				// name:"",
				// email:"",
				// phone:"",
				// //头像
				// avatar_url:""
			}
		},
		onLoad() {
			const antu = this.$u.utils.isLogin()
			if(!antu) return
			//填充用户信息
			// this.name = this.vuex_user.name
			// this.email = this.vuex_user.email
			// this.avatar_url = this.vuex_user.avatar_url
			// this.phone = this.vuex_user.phone
			
			
		},
		methods: {
			toModifyInfo(){
				this.$u.route({
					url:"pages/center/modifyInfo"
				})
			},
			async exitLogin(){
				//退出登录
				const res = await this.$u.api.authExitLogin()
				this.$u.toast("成功退出登录")
				//跳转首页
				setTimeout(()=>{
					//清除本地信息
					this.$u.vuex("vuex_token","")
					this.$u.vuex("vuex_user",{})
					
					this.$u.route({
						type:"reLaunch",
						url:"pages/index/index"
					})
				},1500)
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #ededed;
	}
	
	.camera{
		width: 54px;
		height: 44px;
		
		&:active{
			background-color: #ededed;
		}
	}
	.user-box{
		background-color: #fff;
	}
</style>
